<template>
  <div>
    <h2 style="text-align: center">投标书信息</h2>
    <el-row>
      <el-col :span="5">
        标题：
        <el-input size="large" style="width: 200px;" v-model="queryObj.title" placeholder="请输入投标书标题"/>
      </el-col>
      <el-col :span="6">
        起始日期：
        <el-date-picker
            v-model="queryObj.startDate"
            type="date"
            placeholder="请选择开始日期"
            size="large"
            value-format="YYYY-MM-DD"
        />
      </el-col>
      <el-col :span="6">
        结束日期：
        <el-date-picker
            v-model="queryObj.endDate"
            type="date"
            placeholder="请选择结束日期"
            size="large"
            value-format="YYYY-MM-DD"
        />
      </el-col>

      <el-col :span="1">
        <el-button type="primary" @click="findBidd(1)">搜索</el-button>
      </el-col>
    </el-row>

    <el-table :data="biddList" stripe height="335" style="width: 100%">
      <el-table-column label="投标书编号" prop="biddId"/>
      <el-table-column label="标题" prop="title"/>
      <el-table-column label="时间" prop="date"/>
      <el-table-column label="操作">
        <template #default="scope">
          <el-badge class="item">
            <el-button size="default" type="primary" @click="findById(scope.row.id),showFindById=true">
              查看详情
            </el-button>
          </el-badge>
        </template>
      </el-table-column>
    </el-table>

    <el-dialog v-model="showFindById" :title="biddObj.title" width="30%" :before-close="handleClose" center>
      时间:{{ biddObj.date }}<br><br>
      <div v-html="biddObj.info" style="height:200px;width: 400px;border: black 1px solid"></div>

      <template #footer>
      <span class="dialog-footer">
        <el-button @click="showFindById = false">取消</el-button>
      </span>
      </template>
    </el-dialog>

    <el-pagination
        v-model:current-page="currentPage"
        v-model:page-size="pageSize"
        background
        layout="prev, pager, next, jumper"
        :total="total"
        @current-change="findBidd"
    />
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      biddList: [],
      total: 0,
      currentPage: 1,
      pageSize: 6,
      queryObj: {},
      biddObj: {},
      showFindById: false,
    }
  },
methods: {
  findBidd(pageNO) {
    this.currentPage = pageNO;
    this.queryObj.pageNO = pageNO
    axios.get("/project/bidd/cutByItem", {params: this.queryObj})
        .then(resp => {
          let obj = resp.data;
          if (obj.success) {
            this.biddList = obj.data.records;
            console.log(obj.data.records)
            this.total = obj.data.total;
            this.pageSize = obj.data.size
          }
        })
  },
  findById(id) {
    axios.get("/project/bidd/findById", {params: {id}})
        .then(resp => {
          let obj = resp.data;
          if (obj.success) {
            this.biddObj = obj.data
            console.log(obj.data)
          }
        })
  }
}, created() {
  this.findBidd(1)
}
}
</script>

<style scoped>

</style>